package com.wumeng.dynamicmultidatabase01.modules.user.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.wumeng.dynamicmultidatabase01.modules.user.dao.User;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Component;

import java.sql.Timestamp;
import java.util.Map;


/**
 * @author wumeng 2022/6/8 5:18 下午
 */
@Component
public interface UserMapper extends BaseMapper<User> {
    @Insert("insert into User(id,name,create_time) values(#{id},#{name},#{create_time})")
    int add(User User);

    @Update("update User set name=#{name},create_time=#{create_time} where id=#{id}")
    int update(User User);

    //@Delete("delete from User where sno=#{sno}")
    void deleteById(int id);

    @Select("select * from User where id=#{id}")
    @Results(id = "User",value= {
            @Result(property = "id", column = "id", javaType = int.class),
            @Result(property = "name", column = "name", javaType = String.class),
            @Result(property = "create_time", column = "create_time", javaType = Timestamp.class)
    })
    User queryUserById(int id);

    User queryUserByState(String state);

    Map<String,Object> getDynamicUser(String tableName,String columns);

}
